#ifndef __DS1302_H__
#define __DS1302_H__

#include "STC15F2K60S2.h"
#include <intrins.h>

#define uint unsigned int
#define uchar unsigned char


//对端口重新定义,位变量，只进行逻辑判断，非零即真
sbit DS1302_CE   = P1^3;
sbit DS1302_IO   = P2^3;
sbit DS1302_SCLK = P1^7;

//宏定义封装代码
#define DS1302_SECOND   0x80	//秒
#define DS1302_MINTUE   0x82	//分钟
#define DS1302_HOUR     0x84	//小时
#define DS1302_DATE     0x86	//日
#define DS1302_MONTH    0x88	//月
#define DS1302_DAY      0x8A	//星期
#define DS1302_YEAR     0x8C	//年
#define DS1302_WP       0x8E	//写保护的


extern unsigned char DS1302_Time[9];//年月日时分秒星期
	//外部变量必须加extern，外部数组或函数可以不加extern


void DS1302_Init(void);//DS1302 初始化函数
void DS1302_WriteByte(unsigned char Command, unsigned char Data);//DS1302写一个字节
unsigned char DS1302_ReadByte(unsigned char Command);//DS1302读一个字节

void DS1302_SetTime(void);	//设置时间
void DS1302_ReadTime(void);	//读取时间




/* 官方驱动
sbit SCK = P1^7;		
sbit SDA = P2^3;		
sbit RST = P1^3;   // DS1302复位

void Write_Ds1302(unsigned char temp);
void Write_Ds1302_Byte( unsigned char address,unsigned char dat );
unsigned char Read_Ds1302_Byte( unsigned char address );
*/
#endif
